package com.kds.changzhou.data;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.Collection;
import java.util.LinkedList;

/**
 * @author 孔德嵩
 */
public class Gateway {

    private Integer sequence;
    private String buildingCode;
    private String gatewayId;
    private Collection<Function> functions;


    public Gateway(String buildingCode, String gatewayId) {
        this.buildingCode = buildingCode;
        this.gatewayId = gatewayId;
        this.functions = new LinkedList<>();
        this.sequence = 1;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (o == null || getClass() != o.getClass()) return false;

        Gateway gateway = (Gateway) o;

        return new EqualsBuilder().append(buildingCode, gateway.buildingCode).append(gatewayId, gateway.gatewayId).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).append(buildingCode).append(gatewayId).toHashCode();
    }

    public String getBuildingCode() {
        return buildingCode;
    }

    public void setBuildingCode(String buildingCode) {
        this.buildingCode = buildingCode;
    }

    public String getGatewayId() {
        return gatewayId;
    }

    public void setGatewayId(String gatewayId) {
        this.gatewayId = gatewayId;
    }

    public Collection<Function> getFunctions() {
        return functions;
    }

    public void setFunctions(Collection<Function> functions) {
        this.functions = functions;
    }

    public Integer getSequence() {
        return sequence++;
    }
}
